#include "strugen.h"

int
main(int argc, char *argv[])
{
  if (argc!=2) {
    printf("Usage: %s data_file", argv[0]);
    exit(1);
  } 

  FILE *fp;
  if ((fp=fopen(argv[1], "rb"))==NULL) {
    printf("cannot open file %s!\n", argv[1]);
    exit(1);
  }

  int count, i, result;
  BYTE *buf;
  void *bill;
  billinit(&bill, &buf);

  while (count=billread(buf, fp)) {
    result=billstrugen(bill, buf);
    for (i=0; i<count; i++) {
      billverify(bill);
      char *str=bill2string(bill);
      printf("%s\n", str);
      result=billstrugen(bill, NULL);
    }
  }
  
  billdestroy(bill, buf);
  if (fclose(fp))
    printf("file close error!");

  return 0;
}
